package com.thirteen.app.controller;

import com.thirteen.app.dto.CreateExamRequest.ExamDto;
import com.thirteen.app.service.CourseService;
import com.thirteen.app.service.ExamService;
import com.thirteen.app.service.PaperService;
import com.thirteen.app.utils.tools.CommonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags = {"创建考试"})
@RestController
@RequestMapping("/api/teacher/exam")
@CrossOrigin
public class CreateExamController {

    @Resource
    CourseService courseService;

    @Resource
    PaperService paperService;

    @Resource
    ExamService examService;

    /**暂时无用*/
//    @ApiOperation("分页查找所有课程")
//    @GetMapping("getCourseBySearch")
//    public CommonResult queryCourse(String courseName,Integer offset,Integer limit) {
//        return CommonResult.success(courseService.queryAllCourse(courseName,offset,limit));
//    }
//
//    @ApiOperation("分页查找根据课程查找试卷")
//    @GetMapping("getPaperBySearch")
//    public CommonResult queryPaper(Integer courseId,String paperName,Integer offset,Integer limit) {
//        return CommonResult.success(paperService.queryAllPaperByCourseId(courseId,paperName,offset,limit));
//    }

    /**
     * 暂时无用
     */

    @ApiOperation("列表查询")
    @GetMapping("getCourseAndPaper")
    public CommonResult queryAllCourseAndPaper() {
        return CommonResult.success(courseService.queryAllCourseAndPaper());
    }

    @ApiOperation("获取试卷简略信息")
    @GetMapping("getPaperInfo")
    public CommonResult getPaper(Integer paperId) {
        System.out.println(paperService.queryPaperInfo(paperId).toString());
        return CommonResult.success(paperService.queryPaperInfo(paperId));
    }

    @ApiOperation("创建考试")
    @PostMapping("createExam")
    public CommonResult createExam(@RequestBody ExamDto examDto) {
        System.out.println(examDto.toString());
        examService.insertExam(examDto);
        return CommonResult.success(examDto);
    }

}
